package com.example.demo.Controller;

import com.example.demo.model.Message;
import com.example.demo.model.MessageMapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;

@RestController
public class MessageController {
    @Resource
    private MessageMapper messageMapper;
    @GetMapping("/message")
    public Object getMessage(int sessionId){
        List<Message> messages = messageMapper.getMessageBySessionId(sessionId);
//      数据库是按照时间升序查，但是显示要降序显示
        Collections.reverse(messages);
        return messages;
    }

}